﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="detailandmed_v4_hy_liige", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(DetailandmedV4HyLiige))]
    public class DetailandmedV4HyLiigeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IDetailandmedV4HyLiige clazz;
        
        public DetailandmedV4HyLiigeSerializer(IDetailandmedV4HyLiige clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.IsikuTyyp!=null) {
                Writer.WriteStartElement("isiku_tyyp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuTyyp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Eesnimi!=null) {
                Writer.WriteStartElement("eesnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NimiArinimi!=null) {
                Writer.WriteStartElement("nimi_arinimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NimiArinimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.IsikukoodRegistrikood!=null) {
                Writer.WriteStartElement("isikukood_registrikood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikukoodRegistrikood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ValisKood!=null) {
                Writer.WriteStartElement("valis_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ValisKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ValisKoodRiik!=null) {
                Writer.WriteStartElement("valis_kood_riik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ValisKoodRiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ValisKoodRiikTekstina!=null) {
                Writer.WriteStartElement("valis_kood_riik_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ValisKoodRiikTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Synniaeg!=null) {
                Writer.WriteStartElement("synniaeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Synniaeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Osamaks!=null) {
                Writer.WriteStartElement("osamaks");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Osamaks))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressRiik!=null) {
                Writer.WriteStartElement("aadress_riik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressRiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressRiikTekstina!=null) {
                Writer.WriteStartElement("aadress_riik_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressRiikTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressEhak!=null) {
                Writer.WriteStartElement("aadress_ehak");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressEhak))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressEhakTekstina!=null) {
                Writer.WriteStartElement("aadress_ehak_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressEhakTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressTanavMajaKorter!=null) {
                Writer.WriteStartElement("aadress_tanav_maja_korter");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressTanavMajaKorter))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Omandiliik!=null) {
                Writer.WriteStartElement("omandiliik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Omandiliik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OmandiliikTekstina!=null) {
                Writer.WriteStartElement("omandiliik_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmandiliikTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MurdosaLugeja!=null) {
                Writer.WriteStartElement("murdosa_lugeja");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.MurdosaLugeja))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MurdosaNimetaja!=null) {
                Writer.WriteStartElement("murdosa_nimetaja");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.MurdosaNimetaja))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKpv!=null) {
                Writer.WriteStartElement("algus_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoppKpv!=null) {
                Writer.WriteStartElement("lopp_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Grupp!=null) {
                Writer.WriteStartElement("grupp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Grupp))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="isiku_tyyp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>isiku_tyyp");
                }
                clazz.IsikuTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isiku_tyyp")).Value;
            }
            if (Reader.LocalName=="eesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>eesnimi");
                }
                clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
            }
            if (Reader.LocalName=="nimi_arinimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>nimi_arinimi");
                }
                clazz.NimiArinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("nimi_arinimi")).Value;
            }
            if (Reader.LocalName=="isikukood_registrikood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>isikukood_registrikood");
                }
                clazz.IsikukoodRegistrikood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood_registrikood")).Value;
            }
            if (Reader.LocalName=="valis_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>valis_kood");
                }
                clazz.ValisKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("valis_kood")).Value;
            }
            if (Reader.LocalName=="valis_kood_riik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>valis_kood_riik");
                }
                clazz.ValisKoodRiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("valis_kood_riik")).Value;
            }
            if (Reader.LocalName=="valis_kood_riik_tekstina") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ValisKoodRiikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("valis_kood_riik_tekstina")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="synniaeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>synniaeg");
                }
                clazz.Synniaeg = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("synniaeg")).Value;
            }
            if (Reader.LocalName=="osamaks") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>osamaks");
                }
                clazz.Osamaks = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("osamaks")).Value;
            }
            if (Reader.LocalName=="aadress_riik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>aadress_riik");
                }
                clazz.AadressRiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_riik")).Value;
            }
            if (Reader.LocalName=="aadress_riik_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>aadress_riik_tekstina");
                }
                clazz.AadressRiikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_riik_tekstina")).Value;
            }
            if (Reader.LocalName=="aadress_ehak") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>aadress_ehak");
                }
                clazz.AadressEhak = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_ehak")).Value;
            }
            if (Reader.LocalName=="aadress_ehak_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>aadress_ehak_tekstina");
                }
                clazz.AadressEhakTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_ehak_tekstina")).Value;
            }
            if (Reader.LocalName=="aadress_tanav_maja_korter") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>aadress_tanav_maja_korter");
                }
                clazz.AadressTanavMajaKorter = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_tanav_maja_korter")).Value;
            }
            if (Reader.LocalName=="omandiliik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>omandiliik");
                }
                clazz.Omandiliik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("omandiliik")).Value;
            }
            if (Reader.LocalName=="omandiliik_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>omandiliik_tekstina");
                }
                clazz.OmandiliikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("omandiliik_tekstina")).Value;
            }
            if (Reader.LocalName=="murdosa_lugeja") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>murdosa_lugeja");
                }
                clazz.MurdosaLugeja = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("murdosa_lugeja")).Value;
            }
            if (Reader.LocalName=="murdosa_nimetaja") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>murdosa_nimetaja");
                }
                clazz.MurdosaNimetaja = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("murdosa_nimetaja")).Value;
            }
            if (Reader.LocalName=="algus_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>algus_kpv");
                }
                clazz.AlgusKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kpv")).Value;
            }
            if (Reader.LocalName=="lopp_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>lopp_kpv");
                }
                clazz.LoppKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kpv")).Value;
            }
            if (Reader.LocalName=="grupp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v4_hy_liige>grupp");
                }
                clazz.Grupp = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("grupp")).Value;
            }
        }
    }
}
